package io.github.yotta.dict.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yotta
 * @date 2025/8/12
 */
@AllArgsConstructor
@Getter
public enum SysDictStatus {

    NORMAL(0, "正常"),

    DISABLED(1, "禁用");

    private final Integer code;
    private final String message;

    private static final Map<Integer, SysDictStatus> codeMap = new HashMap<>();

    static {
        for (SysDictStatus value : values()) {
            codeMap.put(value.code, value);
        }
    }

    public static SysDictStatus of(Integer code) {
        SysDictStatus sysDictStatus = codeMap.get(code);
        if (sysDictStatus == null) {
            throw new IllegalArgumentException("Unknown SysDictStatus Code: " + code);
        }
        return sysDictStatus;
    }
}
